import 'package:aone_common/common.dart';
import 'package:app01/views/home/home_controller.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class HomeView extends GetView<HomeController> {
  const HomeView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<HomeController>(
        autoRemove: false,
        init: HomeController(),
        builder: (_) {
          return Scaffold(
              body: Stack(
            children: <Widget>[
              Builder(
                builder: (BuildContext ctx) {
                  return Stack(
                    children: [
                      Positioned(
                          left: 0,
                          top: 0,
                          right: 0,
                          bottom: 0,
                          child: Image.asset(
                            'images/assets/BG 2.png',
                            fit: BoxFit.fill,
                          )),
                      Positioned(
                          left: 0,
                          right: 0,
                          bottom: 0,
                          top: 40,
                          child: listView()),
                      Positioned(
                          left: 0,
                          right: 0,
                          height: 40,
                          top: 40,
                          child: _barView()),
                    ],
                  );
                },
              ),
            ],
          ));
        });
  }

  Widget _barView() {
    return Container(
      margin: EdgeInsets.only(
          left: ScreenUtil().setWidth(14), right: ScreenUtil().setWidth(14)),
      height: 40,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          GestureDetector(
            onTap: () {
              print(11111);
              Get.toNamed(Routes.login);
            },
            child: Container(
              color: Colors.transparent,
              child: Row(
                children: [
                  Image.asset(
                    'images/assets/user.png',
                  ),
                  const Text(
                    ' 未登录',
                    style: TextStyle(
                        color: Color.fromRGBO(255, 255, 255, 1),
                        fontSize: 10,
                        fontWeight: FontWeight.bold),
                  )
                ],
              ),
            ),
          ),
          Image.asset(
            'images/assets/logo_white.png',
          ),
          Row(
            children: [
              Column(
                children: [
                  Image.asset(
                    'images/assets/take_money.png',
                  ),
                  const Text(
                    '取款',
                    style: TextStyle(
                        color: Color.fromRGBO(255, 255, 255, 1),
                        fontSize: 10,
                        fontWeight: FontWeight.bold),
                  )
                ],
              ),
              const SizedBox(
                width: 13,
              ),
              Column(
                children: [
                  Image.asset(
                    'images/assets/save_money.png',
                  ),
                  const Text(
                    '存款',
                    style: TextStyle(
                        color: Color.fromRGBO(255, 255, 255, 1),
                        fontSize: 10,
                        fontWeight: FontWeight.bold),
                  )
                ],
              )
            ],
          )
        ],
      ),
    );
  }

  Widget listView() {
    return ListView(
      children: [
        Container(
          height: 100,
          color: Colors.red,
        )
      ],
    );
  }
}
